package one.bugu.android.demon.constant;

import android.app.Activity;
import android.content.Context;
import android.support.v4.app.ActivityCompat;
import com.juefeng.android.framework.common.util.SDCardUtil;

import java.io.File;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: LangK
 * Date: 2017/12/14
 * Time: 15:50
 * Description:文件常量类
 */
public class FileConstant {

    /**
     * 获取攻略类型的缓存文件
     *
     * @return
     */
    public static String getStrategyTypeFile(Context context) {
        try {
            String fileName = "strateType.cache";
            File file;
            if (SDCardUtil.checkSdCard(context)) {
                file = new File(SDCardUtil.getExternalCacheDir(context) + "/" + fileName);
            } else {
                file = new File(context.getCacheDir().getAbsolutePath() + "/" + fileName);
            }
            if (!file.exists()) {
                file.createNewFile();
            }
            return file.getAbsolutePath();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }


    /**
     * 获取地图类型的缓存文件
     *
     * @return
     */
    public static String getMapTypeFile(Context context) {
        try {
            String fileName = "mapType.cache";
            File file;
            if (SDCardUtil.checkSdCard(context)) {
                file = new File(SDCardUtil.getExternalCacheDir(context) + "/" + fileName);
            } else {
                file = new File(context.getCacheDir().getAbsolutePath() + "/" + fileName);
            }
            if (!file.exists()) {
                file.createNewFile();
            }
            return file.getAbsolutePath();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }

    }

}
